# 基础镜像
FROM ubuntu:20.04
# 镜像作者
MAINTAINER Jianjun.Liu 1146190118@qq.com

COPY sources.list /etc/apt/sources.list

# 执行命令
RUN apt-get update -y \
    && apt-get install git -y \
    && DEBIAN_FRONTEND=noninteractive apt-get install nginx -y \
    && service nginx start \
    && apt-get install python3 -y \
    && apt-get install python3-pip -y

# 增加文件
WORKDIR /home/
# 通过git 下载project
RUN git clone https://gitee.com/liuji13x/meiduo_project.git

# pip 安装包
WORKDIR /home/meiduo_project/
RUN pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# celery 运行
WORKDIR /home/meiduo_project/meiduo_mall
RUN celery multi start worker -A celery_tasks.main -l info --logfile=celerylog.log --pidfile=celerypid.pid
# nginx 配置
RUN cp /home/meiduo_project/meiduo_mall/docs/meiduo_nginx.conf /etc/nginx/conf.d/ \
    && cp docs/nginx.conf /etc/nginx/ \
    && service nginx reload

# 设置环境变量；作用：指定系统语言为UTF-8；如果不设置，uwsgi运行无法处理中文语言
ENV LC_ALL="zh_CN.utf8"

# 项目运行
WORKDIR /home/meiduo_project/meiduo_mall/
# 对外端口
EXPOSE 80

COPY command.sh /home/meiduo_project/meiduo_mall/
# 运行项目
ENTRYPOINT ["/bin/bash", "command.sh"]
